import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.mime.application import MIMEApplication

# 设置发件人和收件人信息
sender_email = "yyqqm@163.com"
receiver_email = "kklives@qq.com"
password = "QYJYKWMQDGJMKTQM"


def send_alert(subject, text):
    message = MIMEMultipart()
    message["From"] = sender_email
    message["To"] = receiver_email
    message["Subject"] = subject
    message.attach(MIMEText(text, "plain"))
    try:
        server = smtplib.SMTP_SSL("smtp.163.com", 465)
        # server.starttls()
        server.login(sender_email, password)
        server.sendmail(sender_email, receiver_email, message.as_string())
        server.quit()
    except Exception as e:
        print("邮件发送失败:", str(e))
# send_alert("465","测试邮件内容")
